###############################################################################
#
# $Id: GNUmakefile,v 1.19 2008/08/01 00:41:04 terabrit Exp $ $Name: V113 $
#
# The contents of this file are subject to the AAF SDK Public
# Source License Agreement (the "License"); You may not use this file
# except in compliance with the License.  The License is available in
# AAFSDKPSL.TXT, or you may obtain a copy of the License from the AAF
# Association or its successor.
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See
# the License for the specific language governing rights and limitations
# under the License.
#
# The Original Code of this file is Copyright 1998-2004, Licensor of the
# AAF Association.
#
# The Initial Developer of the Original Code of this file and the
# Licensor of the AAF Association is Avid Technology.
# All rights reserved.
#
###############################################################################

#------------------------------------------------------------------------------
#
#
#------------------------------------------------------------------------------
PACKAGE = Utilities

AAFBASE ?= ../..


# Common definitions
include $(AAFBASE)/build/common.mk


# Include directories
INCLUDES = -I$(AAFSDKINCLUDEDIR) \
		-I../Include \
	   -I../../OMF/Include \
	   -I../../OMF/portinc


# CXXOBJS2 is the list of files used to create the executable.
CXXFILES2 = AafOmfMain.$(CPP_EXTENSION)


# LIBCXXOBJS is the list of object file used to create the library.
# It's generated by taking all the object files from current OBJDIR 
# and removing AafOmfMain.o from the list. 
LIBCXXOBJS = $(filter-out $(OBJDIR)/AafOmfMain$(OBJ), $(CXXOBJS))


LIBTARGET = $(AAFSDKLIBDIR)/libAAFConverterLib$(LIBEXT)
BINTARGET = $(AAFSDKBINDIR)/AafOmf$(EXE)



.PHONY : all
all : $(OBJDIR) $(LIBTARGET) $(BINTARGET)


# Build the library. Note that we use LIBCXXOBJS to not link
# files containing main() function.
$(LIBTARGET) : $(LIBCXXOBJS)
	$(LD_STAT_LIB) $(LD_STAT_OUTPUT) $(LIBCXXOBJS)

ifeq ($(AAFPLATFORM), MipsIrix)

OMFLIBDIR=$(AAFBASE)/OMF/IrixLibs


# Build executable. Note that CXXOBJS2 is used instead of CXXOBJS.
$(BINTARGET) : $(CXXOBJS2) $(LIBTARGET)
	$(LD) $(CXXOBJS2) $(RPATH_OPT) -lAAFConverterLib \
	-L$(OMFLIBDIR) -lAJPG -lOMFI -lbento -ljpeg \
	-L$(AAFSDKLIBDIR) -laaflib -laafiid $(LIBCIO) -o $@ -lm

else

ifeq ($(AAFPLATFORM), Win)
$(BINTARGET) : $(CXXOBJS2) $(LIBTARGET)
	$(LD) $(CXXOBJS2) $(LIBTARGET) \
	../../OMF/WinLibs/omfToolkit.lib \
	../../OMF/WinLibs/libbento.lib \
	../../OMF/WinLibs/libjpeg.lib \
	$(LINK_AAF_APP)
else

$(BINTARGET) : $(CXXOBJS2) $(LIBTARGET)
	@echo "OMF library not available for $(AAFPLATFORM)."

endif

endif

.PHONY : clean
clean :
	@$(RM) $(LIBCXXOBJS)
	@$(RM) $(CXXOBJS2)
	@$(RM) $(DEPS)
	@$(RM) $(LIBTARGET)
	@$(RM) $(BINTARGET)
	@$(RMDIR) $(OBJDIR)/ii_files


.PHONY : realclean
realclean : clean


CFLAGS += -DNO_CONTAINER_EXPORTS


include $(AAFBASE)/build/rules.mk

